package cn.sciento.core.convert.date;

import org.springframework.core.convert.converter.Converter;
import org.springframework.util.StringUtils;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

public class LocalDateConverter implements Converter<String, LocalDate> {
    private static final String DATE_FORMAT = "yyyy-MM-dd";

    public LocalDate convert(String localDate) {
        if (!StringUtils.hasText(localDate))
            return null;
        return LocalDate.parse(localDate, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
    }
}
